package com.mytest.provider.es.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("brand")
public class BrandController {


   /* @Autowired
    private BrandService brandService;*/

    /**
     * 分页查询品牌，把查询到的所有数据信息封装到PageResult中
     * 分页查询最起码要告诉服务器现在查询哪一页，现在的页容量要多少个
     * @param page
     * @param rows
     * @return
     */
    /*@GetMapping("page")
    public ResponseEntity<PageResult<Brand>> page(
            @RequestParam(value = "page",defaultValue = "1")Integer page,
            @RequestParam(value = "rows",defaultValue = "10")Integer rows,
            @RequestParam(value = "sortBy",required = false)String sortBy,
            @RequestParam(value = "desc",required = false)Boolean desc,
            @RequestParam(value = "key",required = false)String key) {

        PageResult<Brand> pageResult = this.brandService.page(page,rows,sortBy,desc,key);

        if (pageResult != null && null!=pageResult.getItems()&&0!=pageResult.getItems().size()) {
            return ResponseEntity.ok(pageResult);
        }

        return ResponseEntity.status(HttpStatus.NO_CONTENT).build();//204
    }*/

    /**
     *
     *
     * 保存品牌，并同时获取品牌对应的分类的id，由于springMVC的消息转换器可以自动的把有特征字符串转为集合数组，所以直接转换
     * @param brand
     * @param cids
     * @return
     */
    /*@PostMapping
    public ResponseEntity<Void> addBrand(Brand brand,@RequestParam("cids") List<Long> cids){

        this.brandService.addBrand(brand,cids);

        return ResponseEntity.status(HttpStatus.CREATED).build();//返回201表示注册完成

    }

    @PutMapping
    public ResponseEntity<Void> updateBrand(Brand brand,@RequestParam("cids") List<Long> cids){

        this.brandService.updateBrand(brand,cids);

        return ResponseEntity.status(HttpStatus.CREATED).build();//返回201表示注册完成

    }*/

    /**
     * 根据分类的id查询分类对应的品牌信息
     *
     * @param cid
     * @return
     */
   /* @GetMapping("cid/{cid}")
    public ResponseEntity<List<Brand>> queryBrandByCategory(@PathVariable("cid")Long cid){

        //根据分类的id查询分类对应的品牌信息
        List<Brand> brands = this.brandService.queryBrandByCategory(cid);

        if (brands != null && 0!=brands.size()) {
            return ResponseEntity.ok(brands);
        }

        return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
    }*/
}
